#ifndef MAGIC_H
#define MAGIC_H

#include "model.h"
#include "engine.h"


class Magic{
public:
	Model myModel;
	vec3 pos;
	float time;
	bool casted;
	
	Magic(){
		Model myModel;
		vec3 pos = vec3(0,0,0);
		time = 0;
		casted = false;
	}
	
	void set(Camera cam){
		pos = vec3(cam.x + cam.lx, cam.y, cam.z - 2);
		time = glutGet(GLUT_ELAPSED_TIME);
		casted = true;
	}
	
	void draw(float timeElapsed, float y){
		if (casted){			
			glPushMatrix();
			glTranslatef(pos[0], y, computeFall(timeElapsed));
			myModel.draw();
			glPopMatrix();
		}
	}
	
	void casting(Camera cam,float currentTime) {
		float timeElapsed = (time - currentTime) /1500;
		float y = timeElapsed + pos[1];

		if(y < cam.floorHeight - .5){
			casted = false;
        }
		else{
			draw(timeElapsed, y);
		}
    }
	
	float computeFall(float fallTime){
		return pos[2] + fallTime * 5;
	}
};

class Spell{
public:
	vector<Magic> magic;
	
	void set(){
		Magic m;
		m.myModel = getInput("Magic.obj");
		
		for (int i = 0; i < maxSpells; i++){
			magic.push_back(m);
		}
	}
	
	void cast(){
		for (int i = 0; i < maxSpells; i++){
			if (!magic[i].casted){
				magic[i].set();
				break;
			}
		}
	}
};

#endif